# encoding:utf-8
from flask import Flask
from flask_cors import CORS
from flask_restful import Api


from common.models import db
from main_app.account.user import user_bp
from main_app.video.video import video_bp

from common.utils.middlewares import jwt_authentication
from logs.logs import setup_log


def cron_test():
    print('这是测试定时任务')


def create_flask_app(config):
    app = Flask(__name__)
    app.config.from_object(config)
    app.before_request(jwt_authentication)
    db.init_app(app)
    app.register_blueprint(user_bp)
    app.register_blueprint(video_bp)

    setup_log('testing')
    cors = CORS(app, resources={r"/*/*": {"origins": "*"}})


    api = Api(app)
    return app
